<template>
    <lightning-card title="LdsDeleteRecord" icon-name="standard:record">
        <template lwc:if={accounts}>
            <div class="slds-var-m-around_medium">
                <template for:each={accounts} for:item="account">
                    <lightning-layout
                        key={account.Id}
                        class="slds-var-m-vertical_x-small"
                    >
                        <lightning-layout-item flexibility="grow">
                            {account.Name}
                        </lightning-layout-item>
                        <lightning-layout-item>
                            <lightning-button-icon
                                icon-name="utility:delete"
                                onclick={deleteAccount}
                                data-recordid={account.Id}
                            ></lightning-button-icon>
                        </lightning-layout-item>
                    </lightning-layout>
                </template>
            </div>
        </template>
        <template lwc:elseif={error}>
            <c-error-panel errors={error}></c-error-panel>
        </template>

        <c-view-source source="lwc/ldsDeleteRecord" slot="footer">
            Delete a record without writing server-side code.
        </c-view-source>
    </lightning-card>
</template>
